package com.hernie.piggymall.member.web;

import com.hernie.common.utils.R;
import com.hernie.piggymall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author HuangJp
 * @Date 2022/5/25
 * @Description
 */
@Controller
public class MemberWebController {

    @Autowired
    private OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                  Model model) {
        // 获取到支付宝传来的所有请求数据
        // request  验证签名，如果正确可以去修改
        // 查出当前登录用户的所有订单列表数据
        Map<String, Object> map = new HashMap<>();
        map.put("page", pageNum.toString());
        R r = orderFeignService.listWithItem(map);
        model.addAttribute("orders", r);
        return "orderList";
    }
}
